import re

my_string = """{"appType":3,"checkRegisterSmsFlag": "#smsflag#",
                "mobile": "#mobile#",
                "userName":"#username#",
                "password":"123456",
                "registerOrBind":1,
                "validateType":1}"""

# 解决什么问题？
# smsflag
class Data:
    smsflag = 'fwoefwfwfwofwofo'
    mobile = '18109875643'
    username = 'yuze123'


result = re.finditer('#(.+?)#', my_string)
for el in result:
    target = el.group()  # #smsflag#
    prop = el.group(1)   #
    value = getattr(Data, prop)
    my_string = my_string.replace(target, value )





